﻿using SqlSugar;
using BootstrapBlazor.Components;
using System.Text.Json.Serialization;

namespace HelloApp.Server.Data
{
    public class Material
    {
        [AutoGenerateColumn(Text = "ID", TextWrap = true, Visible =false,IsVisibleWhenEdit =false,IsVisibleWhenAdd =false)]
        [SugarColumn(IsPrimaryKey =true)]
        public Guid Id { get; set; } = Guid.NewGuid();

        [AutoGenerateColumn(Text ="材料名称",TextWrap =true)]
        public string MaterialName { get; set; }=string.Empty;

        [AutoGenerateColumn(Text = "材料编码", TextWrap = true)]
        public string MaterialCode { get; set; } = string.Empty;

        [AutoGenerateColumn(Text = "材料类型")]
        public MaterialType MaterialType { get; set; }

        [AutoGenerateColumn(Text = "材料单价")]
        public float Price { get; set; }

        [AutoGenerateColumn(Text = "材料单位")]
        public string MaterialUnit { get; set; } = string.Empty;

        [AutoGenerateColumn(Text = "图片")]
        [SugarColumn(IsJson =true)]
        public Image Image { get; set; } = new Image();

        [AutoGenerateColumn(Text = "创建时间", TextWrap = true, Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false,FormatString ="yyyy/MM/dd hh:mm")]
        [SugarColumn(InsertServerTime = true)]
        public DateTime CreateTime { get; set; }

        [AutoGenerateColumn(Text = "更新时间", TextWrap = true, Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false, FormatString = "yyyy/MM/dd hh:mm")]
        [SugarColumn(UpdateServerTime =true,InsertServerTime =true)]
        public DateTime UpdateTime { get; set; }
    }
    
    public enum MaterialType
    {
        面料,
        海绵
    }

    public class Image
    {
        public Guid Id { get; set; } = Guid.NewGuid();

        public string FileName { get; set; } = string.Empty;

        public string Url { get; set; } = string.Empty;
    }
}
